package com.sakura.product.controller;

import com.sakura.product.servie.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Sakura
 * @date 2023/7/19 11:35
 */
@RestController
@RequestMapping("/product")
public class ProductController {

    @Value("${server.port}")
    String port;

    @Autowired
    private ProductService productService;
    @RequestMapping("/get/{id}")
    public String get(@PathVariable("id") Integer id) throws Exception {
        System.out.println("查询商品信息ID：" + id);
        return "查询商品信息ID：" + id + "      服务端口：" + port;
    }


    @GetMapping("/getUnitPrice/{productNo}")
    public Integer getUnitPrice(@PathVariable("productNo") String productNo) throws Exception {
        return productService.getUnitPrice(productNo);
    }
    @GetMapping("/getProductName/{productNo}")
    public String getProductName(@PathVariable("productNo") String productNo) throws Exception {
        return productService.getProductName(productNo);
    }
}

